package com.tomecode.tools.maven.settings.config;

import java.io.File;

/**
 * Basic info about maven
 * 
 * @author Tomas Frastia
 * @see http://www.tomecode.com or
 *      http://code.google.com/p/maven-settings-editor/
 * 
 */
public final class Maven {

	private boolean active;
	private MavenVersion version;
	private File home;
	private File repository;

	public Maven() {
		version = MavenVersion.UNKNOWN;
	}

	public final boolean isActive() {
		return active;
	}

	public final void setActive(boolean active) {
		this.active = active;
	}

	/**
	 * version of maven supported only {@link MavenVersion}
	 * 
	 * @return
	 */
	public final MavenVersion getVersion() {
		return version;
	}

	public final File getHome() {
		return home;
	}

	public final void setHome(File home) {
		this.home = home;
	}

	public final File getRepository() {
		return repository;
	}

	public final void setRepository(File repository) {
		this.repository = repository;
	}

	public final void setHome(String home) {
		if (home != null && home.length() != 0) {
			this.home = new File(home);
		} else {
			this.home = null;
		}
	}

	public final void setRepository(String repo) {
		if (repo != null && repo.length() != 0) {
			this.repository = new File(repo);
		} else {
			this.repository = null;
		}
	}

	public final void setActive(String active) {
		this.active = Boolean.parseBoolean(active);
	}

	public final void setVersion(String mavenVersion) {
		this.version = MavenVersion.parse(mavenVersion);
	}
}
